
package SIMRS.Kasir.widget;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.border.Border;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import usu.util.StringUtil;
import usu.widget.text.DefaultDocument;

/**
 *
 * @author Prayitno
 */
public class TextBox extends usu.widget.glass.TextBoxGlass{
    private static final long serialVersionUID = 1L;

    public TextBox() {
        super();
        setFont(getFont().deriveFont(Font.BOLD));
        setForeground(Color.BLACK);
        setSelectionColor(Color.blue.brighter());
        setCaretColor(Color.BLUE);
        //setBorder(Color.GREEN);
        setHorizontalAlignment(LEFT);
        addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                selectAll();
            }            
        });
        setDocument(new DefaultDocument(){
            private static final long serialVersionUID = 1L;
            @Override
            public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
                if(StringUtil.containQuote(str)){
                    return;
                }
                super.insertString(offs, str, a);
            }
        });
    }

    
}
